//
//  Hear_SearchCell.m
//  Hear
//
//  Created by mac on 2018/4/27.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "Hear_SearchCell.h"

@interface Hear_SearchCell()

@property (nonatomic, strong) UIView *colorview;

@end

@implementation Hear_SearchCell

- (void)setBackcorlor:(UIColor *)backcorlor {
    self.colorview.backgroundColor = backcorlor;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor colorWithHexString:@"#EBEBEB"];
    
    UIView *top = [UIView new];
    top.backgroundColor = [UIColor colorWithHexString:@"#EBEBEB"];
    [self.contentView addSubview:top];
    
    UIView *bottom = [UIView new];
    bottom.backgroundColor = [UIColor colorWithHexString:@"#EBEBEB"];
    [self.contentView addSubview:bottom];
    
    UIView *bgview = [UIView new];
    bgview.backgroundColor = [UIColor whiteColor];
    bgview.layer.cornerRadius = 5;
    bgview.layer.masksToBounds = YES;
    [self.contentView addSubview:bgview];
    
    UIView *colorview = [UIView new];
    colorview.layer.cornerRadius = 5;
    colorview.layer.masksToBounds = YES;
    self.colorview = colorview;
    [bgview addSubview:colorview];
    
    UIView *labelview = [UIView new];
    labelview.backgroundColor = [UIColor whiteColor];
    [bgview addSubview:labelview];
    
    UILabel *titleLB = [UILabel new];
    titleLB.font = CustomUIFont(13);
    titleLB.textColor = [UIColor colorWithHexString:@"#222222"];
    self.titleLB = titleLB;
    [labelview addSubview:titleLB];
    
    [top mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.mas_equalTo(self.contentView);
        make.height.mas_equalTo(8.5 * scaleHeight);
    }];
    
    [bgview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(top.mas_bottom);
        make.centerY.mas_equalTo(self.contentView);
        make.leading.mas_equalTo(self.contentView.mas_leading).mas_offset(18 * scaleWidth);
        make.trailing.mas_equalTo(self.contentView.mas_trailing).mas_offset(-18 * scaleWidth);
        make.height.mas_equalTo(50 * scaleHeight);
    }];
    
    [colorview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(top.mas_bottom);
        make.leading.mas_equalTo(bgview.mas_leading);
        make.centerY.mas_equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(8 * scaleWidth, 50 * scaleHeight));
    }];
    
    [labelview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(top.mas_bottom);
        make.centerY.mas_equalTo(self.contentView);
        make.leading.mas_equalTo(colorview.mas_leading).mas_offset(4 * scaleWidth);
        make.trailing.mas_equalTo(bgview.mas_trailing).mas_offset(-18 * scaleWidth);
        make.height.mas_equalTo(50 * scaleHeight);
    }];
    
    [titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(labelview);
        make.leading.mas_equalTo(labelview.mas_leading).mas_offset(10 * scaleWidth);
        make.trailing.mas_equalTo(labelview.mas_trailing).mas_offset(-10 * scaleWidth);
    }];
    
    [bottom mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(bgview.mas_bottom);
        make.leading.trailing.mas_equalTo(self.contentView);
        make.height.mas_equalTo(8.5 * scaleHeight);
    }];
}

@end
